# -*- coding:utf-8 -*-
import csv

# 先读取员工数据
employeeInfos = list()
i = 0
with open('../data/readAndWriteCsv.csv', 'r') as employeefile:
    reader = csv.reader(employeefile)
    for row in reader:
        employeeInfos.append([row[0], row[1]])

# 拼接员工数据并写入CSV
deviceType = 'F500'
sn = 90000000001  # 考勤机编号初始值
perfix = 'zy'  # 考勤机名字前缀
with open('../data/temp.csv', 'w+') as file:
    writer = csv.writer(file)
    while sn <= 90000000500:
        deviveName = perfix + str(i)
        for employeeInfo in employeeInfos:
            empNo = employeeInfo[0]
            empName = employeeInfo[1]
            string = {"deviceSerialNo": str(sn), "deviceSerialName": str(deviveName),
                      "data": [{"type": "2", "objectId": str(empNo), "name": str(empName)}]}
            row = [string]
            writer.writerow(row)
        # 每次序列号+1
        sn = sn + 1
